<!-- Copyright (c) 2008 Thomas Gerber
 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), 
 to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 
 and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.-->
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero" xmlns:odc="clr-namespace:Odyssey.Controls">
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/Odyssey;Component/Themes/BreadcrumbBar/AeroChrome.xaml" />
        <ResourceDictionary Source="pack://application:,,,/Odyssey;Component/Themes/BreadcrumbBar/BreadcrumbButton.xaml" />
        <ResourceDictionary Source="pack://application:,,,/Odyssey;Component/Themes/BreadcrumbBar/BreadcrumbItem.xaml" />
        <ResourceDictionary Source="pack://application:,,,/Odyssey;Component/Themes/BreadcrumbBar/ProgressBar.xaml" />
        <ResourceDictionary Source="pack://application:,,,/Odyssey;Component/Themes/BreadcrumbBar/ButtonTemplates.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <BooleanToVisibilityConverter x:Key="boolToVisible" />
    <ImageSourceConverter x:Key="imgConverter" />

    <ControlTemplate TargetType="{x:Type odc:BreadcrumbBar}" x:Key="BreadcrumbBarTemplate">
        <ControlTemplate.Resources>
            <Style TargetType="{x:Type Button}">
                <Setter Property="Template" Value="{StaticResource ButtonTemplate}" />
                <Setter Property="MinWidth" Value="21" />
                <Setter Property="BorderThickness" Value="1" />
                <Setter Property="FocusVisualStyle" Value="{x:Null}" />
                <Setter Property="BorderBrush" Value="{DynamicResource {ComponentResourceKey odc:Skins, BorderBrush}}" />
                <Setter Property="Focusable"
                        Value="{Binding Focusable, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type odc:BreadcrumbBar}}}" />
            </Style>
            <Style TargetType="{x:Type odc:BreadcrumbButton}">
                <Setter Property="Focusable"
                        Value="{Binding Focusable, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type odc:BreadcrumbBar}}}" />
            </Style>
        </ControlTemplate.Resources>
        <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" Focusable="False"
                BorderThickness="{TemplateBinding BorderThickness}">
            <Border BorderBrush="White" BorderThickness="{TemplateBinding BorderThickness}" Focusable="False">
                <Grid Margin="-1">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <ProgressBar x:Name="progress" Grid.Column="0" Grid.ColumnSpan="4"
                            Maximum="{Binding ProgressMaximum,RelativeSource={RelativeSource TemplatedParent}}"
                            Minimum="{Binding ProgressMinimum,RelativeSource={RelativeSource TemplatedParent}}"
                            Value="{Binding ProgressValue,RelativeSource={RelativeSource TemplatedParent}}" Background="Transparent"
                            BorderThickness="0" Template="{StaticResource progressBarTemplate}" />
                    <odc:BreadcrumbButton ItemsSource="{TemplateBinding CollapsedTraces}" Grid.Column="0" x:Name="PART_Root" MinWidth="0"
                            EnableVisualButtonStyle="False" Mode="{TemplateBinding OverflowMode}"
                            SelectedItem="{Binding SelectedItem,RelativeSource={RelativeSource TemplatedParent},Mode=TwoWay}"
                            ItemTemplate="{TemplateBinding OverflowItemTemplate}" IsImageVisible="True"
                            Image="{Binding SelectedBreadcrumb.Image, RelativeSource={RelativeSource TemplatedParent}}"
                            ItemTemplateSelector="{TemplateBinding OverflowItemTemplateSelector}"
                            IsDropDownPressed="{Binding IsOverflowPressed,RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}">
                    </odc:BreadcrumbButton>
                    <ContentPresenter x:Name="container" Grid.Column="1"
                            Content="{Binding RootItem,RelativeSource={RelativeSource TemplatedParent}}" />
                    <ToggleButton x:Name="dropDown" Grid.Column="2" Focusable="False" Width="16" Visibility="Collapsed"
                            FocusVisualStyle="{x:Null}" Template="{StaticResource DropDownButtonTemplate}" ClickMode="Press"
                            IsChecked="{Binding IsDropDownOpen,RelativeSource={RelativeSource TemplatedParent},Mode=TwoWay}" Margin="-1"
                            BorderThickness="1" BorderBrush="{StaticResource borderBrush}" />
                    <ComboBox x:Name="PART_ComboBox" Visibility="Hidden" Margin="0" IsEditable="True" Focusable="True"
                            ItemTemplate="{TemplateBinding DropDownItemTemplate}"
                            ItemTemplateSelector="{TemplateBinding DropDownItemTemplateSelector}"
                            ItemsSource="{Binding DropDownItems,RelativeSource={RelativeSource TemplatedParent}}" BorderThickness="0"
                            Grid.Column="0"
                            SelectedIndex="{Binding SelectedDropDownIndex,RelativeSource={RelativeSource TemplatedParent},Mode=TwoWay}"
                            Grid.ColumnSpan="3" />
                    <ItemsControl x:Name="buttons" Grid.Column="3" Margin="1,0,-1,0"
                            ItemsSource="{Binding Buttons,RelativeSource={RelativeSource TemplatedParent} }" Focusable="False">
                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                                <StackPanel Orientation="Horizontal" IsItemsHost="True" />
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>
                    </ItemsControl>
                </Grid>
            </Border>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="Visibility" Value="Visible" SourceName="PART_ComboBox">
                <!--hide the breadcrumb container and root button  if the combobox is visible, otherwise a breadcrumb button could get the focus on mouseover: -->
                <Setter Property="Visibility" Value="Hidden" TargetName="container" />
                <Setter Property="Visibility" Value="Hidden" TargetName="PART_Root" />
            </Trigger>
            <Trigger Property="IsRootSelected" Value="True">
                <Setter Property="Visibility" Value="Collapsed" TargetName="PART_Root" />
            </Trigger>
            <Trigger Property="IsMouseOver" Value="True">
                <Trigger.EnterActions>
                    <BeginStoryboard>
                        <Storyboard>
                            <ColorAnimation Duration="0:0:0.10" To="White" Storyboard.TargetProperty="Background.Color" />
                        </Storyboard>
                    </BeginStoryboard>
                </Trigger.EnterActions>
                <Trigger.ExitActions>
                    <BeginStoryboard>
                        <Storyboard>
                            <ColorAnimation Duration="0:0:0.20" From="White" Storyboard.TargetProperty="Background.Color" />
                        </Storyboard>
                    </BeginStoryboard>
                </Trigger.ExitActions>
            </Trigger>
            <Trigger Property="HasDropDownItems" Value="True">
                <Setter Property="Visibility" Value="Visible" TargetName="dropDown" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <!--BreadcrumbBar-->
    <Style TargetType="{x:Type odc:BreadcrumbBar}">
        <Setter Property="MinHeight" Value="23" />
        <Setter Property="Background" Value="#A0FFFFFF" />
        <Setter Property="BorderBrush" Value="{DynamicResource {ComponentResourceKey odc:Skins, BorderBrush}}" />
        <Setter Property="Template" Value="{StaticResource BreadcrumbBarTemplate}" />
    </Style>

</ResourceDictionary>
